#pragma once

class Funds : public boost::noncopyable
{
	struct Serial
	{
		UINT serialNumber;
		double freeze;
	};
	typedef std::map<int,Serial> FundOperateMap;
public:
	explicit Funds(double orginalAmount = 0);

	bool HasEnough(double amount);
	bool Freeze(UINT serialNumber, double amount);
	bool Unfreeze(UINT serialNumber);

	bool Open(double amount, double charge);

	void Loss(double returnAmount, double charge, double lossAmount);
	void Gain(double returnAmount, double charge, double gainAmount);
	void Offset(double returnAmount, double charge, double profit);

	double GetOrginalAmount() const;
	double GetAvailable() const;
	UINT GetFreezeCount() const;
	double GetFreezeAmount(UINT serialNumber) const;

	double GetGainAmount() const { return m_gainAmount; }
	double GetLossAmount() const { return m_lossAmount; }
	double GetProfit() const { return m_gainAmount - m_lossAmount; }
	double GetCharge() const { return m_charge; }

	void SetOrginalAmount(double orginalAmount);

private:
	FundOperateMap m_fundOperateMap;
	double m_orginalAmount;
	double m_available;
	double m_lossAmount;
	double m_gainAmount;
	double m_charge;
};